﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace ConsoleApplication8
{
	class Program
	{
		static void Main(string[] args)
		{
			string test = "abcdefghijklmnopqrstuvwxyz";

			// To retrieve the value of the indexed Chars property using
			// reflection, first get a PropertyInfo for Chars.
			PropertyInfo pinfo = typeof(string).GetProperty("Chars");

			// To retrieve an instance property, the GetValue method
			// requires the object whose property is being accessed and an
			// array of objects representing the index values.

			// Show the seventh letter (g)
			object[] indexArgs = { 6 };
			object value = pinfo.GetValue(test, null);

			Console.WriteLine(value);

			// Show the complete string.
			for (int x = 0; x < test.Length; x++)
			{
				Console.Write(pinfo.GetValue(test, new Object[] { x }));
			}
			Console.ReadKey();
		}
	}
}
